package com.itheima.Demo02;

import java.io.BufferedInputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Demo服务器端 {
    public static void main(String[] args) {
        //创建服务器对象
        //参数代表的是自己的端口
        try {
            ServerSocket ss = new ServerSocket(1314);
            //获取客户端对象 ;
            Socket s = ss.accept();
            //获取输入流
            BufferedInputStream bis = new BufferedInputStream(s.getInputStream());
            //接受数据
            //默认发送的时候就只发了一句话,不需要使用循环读取
            byte[] arr = new byte[1024];
            int len = bis.read(arr);
            System.out.println("客户端对我说:"+new String(arr,0,len));
            bis.close();

        } catch (Exception e) {

        }
    }

}

